<!DOCTYPE html>
<html>
<head>
    <title>Data Transfer Example</title>
    <script type="text/javascript" src="EventUtil.js"></script>
</head>
<body>
    <p>Try dragging the link over to the red square. This won't work correctly in Opera.</p>
    <a href="http://www.wrox.com">Wrox homepage</a>
    <div style="width: 100px; height: 100px; float: right; background: red" id="droptarget"></div>
    <div id="output"></div>
    <script type="text/javascript">
        var droptarget = document.getElementById("droptarget");
        
        function handleEvent(event){
            document.getElementById("output").innerHTML += event.type + "<br>";
            switch(event.type){
                case "drop":
                case "dragdrop":
                    droptarget.innerHTML = event.dataTransfer.getData("url") || event.dataTransfer.getData("text/uri-list");
                    /* falls through */

                case "dropenter":
                case "dragover":
                    EventUtil.preventDefault(event);
                    break;
            }

        }

        EventUtil.addHandler(droptarget, "dragenter", handleEvent);
        EventUtil.addHandler(droptarget, "dragover", handleEvent);
        EventUtil.addHandler(droptarget, "dragleave", handleEvent);
        EventUtil.addHandler(droptarget, "drop", handleEvent);

    </script>
</body>
</html>
